<template>
	<div class="dismissbox">
		<el-row>
			<el-tabs type="border-card">
				<el-tab-pane label="员工离职">
					<el-table :data="changes">
						<el-table-column prop="changeno" label="id"></el-table-column>
						<el-table-column prop="eid" label="员工ID"></el-table-column>
						<el-table-column prop="ename" label="员工姓名"></el-table-column>
						<el-table-column prop="jobx" label="职位"></el-table-column>
						<el-table-column prop="change_date" label="申请时间"></el-table-column>
						<el-table-column prop="dnamex" label="部门"></el-table-column>
						<el-table-column prop="predno" label="部门" v-if="false"></el-table-column>
						<el-table-column prop="state" label="状态"></el-table-column>
						<el-table-column label="操作">
							<template slot-scope="s">
								<el-button type="success" @click="handle(s.$index,s.row)">处理</el-button>
							</template>
						</el-table-column>
					</el-table> 
					<el-dialog title="处理离职" :visible.sync="dialogFormVisible">
						<el-form :model="form" label-width="100px">
							<el-form-item label="员工:">
								<el-input v-model="form.eid" autocoplete="off" disabled></el-input>
							</el-form-item>
							<el-form-item label="处理时间:">
								<el-date-picker type="date" placeholder="选择日期" format="yyyy-M-d" value-format="yyyy-M-d" v-model="form.end_date" style="float:left;" disabled></el-date-picker>
							</el-form-item>
							<el-form-item label="备注信息:">
								<el-input v-model="form.infro" autocoplete="off" disabled></el-input>
							</el-form-item>
								<el-input v-model="form.change_date" autocoplete="off" type="hidden"></el-input>
								<el-input v-model="form.predno" autocoplete="off" type="hidden"></el-input>
								<el-input v-model="form.subdno" autocoplete="off" type="hidden"></el-input>
							<el-button type="primary" @click="sureHandle">确 定</el-button>
						</el-form>
					</el-dialog>
				</el-tab-pane>
			</el-tabs>
		</el-row>
	</div>
</template>

<script>
	export default {
		data() {
			return{
				changes:[],
				me:this.$parent.$parent.$parent.$parent.emp,
				dialogFormVisible:false,
				
				form:{
					changeno:'',
					type:'',
					eid:'',
					predno:'',
					subdno:'',
					change_date:'',
					end_date:'',
					infro:'',
				},
				myindex:-1,
			};
		},
		created(){
			this.$axios.post("showdimisson2").then(v=>{
				console.log(v)
				if(v.data){
					this.changes=v.data;
				}else{
					this.$message.error("出错了！！")
					//alert("出错了！！");
				}
			}).catch(ex=>{
				this.$message.error("出错了！！"+ex)
				//alert("出错了！"+ex);
			})
		},
		methods:{
			handle(index,row){
				var mydate=new Date();
				this.dialogFormVisible=true;
				this.form={
					changeno:row.changeno,
					type:row.type,
					eid:row.eid,
					predno:row.predno,
					subdno:row.predno,
					change_date:row.change_date,
					end_date:mydate.toLocaleDateString(),
					infro:row.infro,
				}
				this.myindex=index;
			},
			sureHandle(){
				this.$axios.post("finishdimiss",this.form).then(v=>{
					console.log(v)
					if(v.data){
						this.$message.success("申请处理成功！！")
						//alert("申请处理成功！！");
					}else{
						this.$message.error("出错了！！")
						//alert("出错了！！");
					}
				}).catch(ex=>{
					this.$message.error("出错了！！"+ex)
					//alert("出错了！"+ex);
				})
				var tos=this.$parent.$parent.$parent.$parent.todos;
				tos.forEach((v)=>{
					if(v.type==63){
						if(v.num>1){
							v.num=v.num-1;
						}else{
							tos.splice(v,1);
						}					
					}
				})
				this.changes.splice(this.myindex,1);
				this.dialogFormVisible=false;
				
			}
		}
	}
</script>

<style>

</style>
